package com.greet.mapper;

import com.greet.annotation.AutoFill;
import com.greet.dto.EmployeePageQueryDTO;
import com.greet.entity.Employee;
import com.greet.enumeration.OperationType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select id, name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user" +
            " from employee where username = #{username}")
    Employee getByUsername(String username);

    @AutoFill(OperationType.INSERT)
    void insert(Employee emp);

    List<Employee> selectPageQuery(EmployeePageQueryDTO employeePageQueryDTO);

    @Select("select count(0) from employee")
    Long countAll();


    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);

    @Select("select id, name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user " +
            "from employee " +
            "where id = #{id}")
    Employee selectById(Long id);
}
